package com.weigee.ktv.v.adapter.rv;

import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.l.d.app.library.adapter.RvListAdapter;
import com.l.d.app.library.util.CalendarUtil;
import com.l.d.app.library.view.CircleColorView;
import com.weigee.ktv.R;
import com.weigee.ktv.m.entity.SystemInformsEntity;
import com.weigee.ktv.m.entity.WrapHolder;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
import skin.support.widget.SkinCompatTextView;

/**
 * Created by 林德 on 2017/4/16 13:35.
 * <p/>
 */
public class SystemInformsAdapter extends RvListAdapter<SystemInformsEntity.DataBean, SystemInformsAdapter.Holder>
{
    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        final View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.systeminforms_frag_rv_item, parent, false);
        return new Holder(itemView);
    }

    @Override
    public void onBindViewHolder(Holder holder, int position)
    {
        final SystemInformsEntity.DataBean bean = getItem(position);
        if (bean == null)
        {
            return;
        }
        holder.tvTitle.setText(bean.getTitle());
        holder.tvMsg.setText(bean.getContent());
        holder.tvTime.setText(CalendarUtil.stringFormat(bean.getCreateTime(), "MM-dd HH:mm", Locale.getDefault()));
    }

    @NonNull
    @Override
    public List<SystemInformsEntity.DataBean> onCreateNewEmptyList()
    {
        return new ArrayList<>();
    }

    static class Holder extends WrapHolder
    {
        @BindView(R.id.civ_img)
        CircleColorView civImg;
        @BindView(R.id.tv_title)
        SkinCompatTextView tvTitle;
        @BindView(R.id.tv_time)
        SkinCompatTextView tvTime;
        @BindView(R.id.tv_msg)
        SkinCompatTextView tvMsg;

        Holder(View view)
        {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
